import axios from '@/utils/request';

/**
 * 从后台获取Guid
 */
 export async function GetGuid() {
    const res = await axios.get('/Attchment/GetGuid');
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
  }


/**
 * 上传文件
 */
 export async function UploadFile(params) {
    const res = await axios.post('/Attchment/UploadFile',params);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 上传文件
 */
 export async function UploadFileStream(params,fdata) {
    const res = await axios.post('/Attchment/UploadFileStream'+ params,fdata);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据id删除文件
 */
 export async function DeleteAttachment(id) {
    const res = await axios.get('/Attchment/DeleteAttachment?id='+id);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据业务id查询文件列表
 */
 export async function QueryAttchmentByBusinessId(businessId) {
    const res = await axios.get('/Attchment/QueryAttchmentByBusinessId?businessId='+businessId);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}
/**
 * 根据业务id查询文件列表
 */
 export async function QueryAttchmentByExtendId(extendId) {
    const res = await axios.get('/Attchment/QueryAttchmentByExtendId?extendId='+extendId);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}



/**
 * 根据车牌号查询文件列表
 */
 export async function QueryAttchmentByCarNumber(carNumber) {
    const res = await axios.post('/Attchment/QueryAttchmentByCarNumber/',carNumber);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

